package com.ltj.springbootrestfuldemo.controller;

import com.ltj.springbootrestfuldemo.pojo.User;
import com.ltj.springbootrestfuldemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/user/getUser", method = RequestMethod.GET)
    @ResponseBody
//    @CrossOrigin
    public User getUser() {
        User user = userService.getUser();
        System.out.println(user.toString());
        return user;
    }

    @RequestMapping(value = "/user/postUser", method = RequestMethod.POST)
    @ResponseBody
    public void postUser(@RequestBody User user) {
        userService.setUser(user);
        System.out.println(user.toString());
    }

}
